# $Id$
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgbase=qca
pkgname=(qca-qt4 qca-qt5)
pkgver=2.1.3
pkgrel=4
pkgdesc="Qt Cryptographic Architecture"
arch=(i686 x86_64)
url="http://delta.affinix.com/qca/"
license=(LGPL)
makedepends=(qt4 qt5-base cmake doxygen nss pkcs11-helper botan1.10 openssl-1.0)
source=("http://download.kde.org/stable/$pkgbase/$pkgver/src/$pkgbase-$pkgver.tar.xz")
md5sums=('5019cc29efcf828681cd93164238ce26')

prepare() {
  mkdir -p build{4,5}
}

build() {
  cd build4
  cmake ../$pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTS=OFF \
    -DQCA_LIBRARY_INSTALL_DIR=/usr/lib \
    -DQCA_FEATURE_INSTALL_DIR=/usr/share/qt4/mkspecs/features/ \
    -DQT4_BUILD=ON \
    -DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 \
    -DOPENSSL_SSL_LIBRARY=/usr/lib/openssl-1.0/libssl.so \
    -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/openssl-1.0/libcrypto.so
  make

  cd ../build5
  cmake ../$pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTS=OFF \
    -DQCA_INSTALL_IN_QT_PREFIX=ON \
    -DQCA_MAN_INSTALL_DIR=/usr/share/man \
    -DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 \
    -DOPENSSL_SSL_LIBRARY=/usr/lib/openssl-1.0/libssl.so \
    -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/openssl-1.0/libcrypto.so
  make
}

package_qca-qt4() {
  depends=(qt4 nss openssl-1.0)
  optdepends=('pkcs11-helper: PKCS-11 plugin' 'botan1.10: botan plugin')
  conflicts=(qca qca-gnupg qca-ossl)
  provides=(qca qca-gnupg qca-ossl)
  replaces=(qca qca-gnupg qca-ossl)

  cd build4
  make DESTDIR="$pkgdir" install
}

package_qca-qt5() {
  depends=(qt5-base nss ca-certificates)
  optdepends=('pkcs11-helper: PKCS-11 plugin' 'botan1.10: botan plugin')

  cd build5
  make DESTDIR="$pkgdir" install
}


